'use strict';

export default class extends think.controller.base {
	/**
	 * some base method in here
	 */
	async __before() {
		this.header("Access-Control-Allow-Origin", this.header("origin") || "*");
		this.header("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
		this.header("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE");
		this.header('Access-Control-Allow-Credentials',true);
		let method = this.http.method.toLowerCase();
		if(method === "options"){
			this.end();
			return false;
		}
		// let userInfo=this.session('userInfo');
		// this.cookie('token', userInfo, {
		// 	timeout: 3600 * 24 * 7 //有效期为一周
		// });
	}
}